//
//  JobCell.m
//  Btpin
//
//  Created by Vic on 2019/3/14.
//  Copyright © 2019 Vic. All rights reserved.
//



#import "JobCell.h"

@interface JobCell ()
{
    UILabel *titleLbl;
    UILabel *baseInfoLbl;
    UILabel *companyNameLbl;
    UIImageView *integrityTagImgView;
    UILabel *companyInfoLbl;
    UIImageView *headerImgView;
    UILabel *hrLbl;
    UILabel *wageLbl;
    UILabel *timeLbl;
}
@end

@implementation JobCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}
- (void)initUI {
    self.bgView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, ScalePS(85)) backgroundColor:COLOR_OF_CLEAR];
    [self.contentView addSubview:self.bgView];
    
    titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(LeftSpace, 15*Scale, WIDTH-100*Scale, 30*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    titleLbl.font = FontBold(Font_18);
    [self.contentView addSubview:titleLbl];
    
    baseInfoLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(titleLbl), EndY(titleLbl), ViewWidth(titleLbl), 25*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
    [self.contentView addSubview:baseInfoLbl];
    
    headerImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(StartX(titleLbl), EndY(baseInfoLbl)+10*Scale, 40*Scale, 40*Scale) imageName:@"header_bg"];
    headerImgView.contentMode = UIViewContentModeScaleAspectFill;
    headerImgView.layer.cornerRadius = 20*Scale;
    headerImgView.layer.masksToBounds = YES;
    [self.contentView addSubview:headerImgView];
    
    companyNameLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(headerImgView)+10*Scale, StartY(headerImgView), 100, 25*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_15];
    [self.contentView addSubview:companyNameLbl];
    
    integrityTagImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(EndX(companyNameLbl)+2, StartY(companyNameLbl)+3*Scale, 14*Scale, 14*Scale) imageName:@"integrity_tag"];
    integrityTagImgView.hidden = YES;
    [self.contentView addSubview:integrityTagImgView];
    
    companyInfoLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(companyNameLbl), EndY(companyNameLbl), WIDTH-80*Scale, 15*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_13];
    [self.contentView addSubview:companyInfoLbl];
    
//    hrLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(headerImgView)+10*Scale, StartY(headerImgView), 200, ViewHeight(headerImgView)) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_12];
//    [self.contentView addSubview:hrLbl];
    
    wageLbl = [UIToolsControl initLabelWithFrame:CGRectMake(WIDTH-200*Scale, 20*Scale, 185*Scale, 17*Scale) text:nil textColor:THEMECOLOR_OF_RED font:Font_15];
    wageLbl.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:wageLbl];
    
    timeLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(wageLbl), EndY(wageLbl)+5*Scale, ViewWidth(wageLbl), ViewHeight(wageLbl)) text:nil textColor:THEMECOLOR_OF_TEXT_cccccc font:Font_12];
    timeLbl.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:timeLbl];
    
    UIView *lineView = [UIToolsControl initViewWithFrame:CGRectMake(0, EndY(headerImgView)+18*Scale, WIDTH, 8*Scale) backgroundColor:THEMECOLOR_OF_GRAY];
    [self.contentView addSubview:lineView];
}
- (void)reloadData {
    titleLbl.text = @"资深程序架构师—App";
    baseInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@ | %@", @"北京", @"通州", @"3-5年", @"本科"];
    
    NSString *companyName = @"同心互联";
    companyNameLbl.text = companyName;
    companyInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", @"天使轮", @"50-100人", @"移动互联网"];
    //    [headerImgView sd_setImageWithURL:[NSURL URLWithString:@""]];
    hrLbl.text = @"罗宏伟.CEO";
    wageLbl.text = @"25K-35K";
    timeLbl.text = @"02月11日";
    
    CGFloat width = [UIToolsControl textWidth:companyName size:CGSizeMake(MAXFLOAT, 25*Scale) font:Font_18]+1;
    companyNameLbl.frame = CGRectMake(StartX(titleLbl), EndY(baseInfoLbl)+5*Scale, width, 20*Scale);
    integrityTagImgView.frame = CGRectMake(EndX(companyNameLbl)+2, StartY(companyNameLbl)+3*Scale, 14*Scale, 14*Scale);
//    companyInfoLbl.frame = CGRectMake(EndX(integrityTagImgView)+3, EndY(companyNameLbl)+8*Scale, 200, 15*Scale);
}
- (void)reloadDataModel:(CompanyJobModel *)model {
    titleLbl.text = model.title;
    baseInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.district_cn, model.experience_cn, model.education_cn];
    
    NSString *companyName = model.company_name;
    companyNameLbl.text = companyName;
    companyInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.finance_cn, model.scale_cn, model.trade_cn];
    if (model.company_logo && model.company_logo.length) {
        [headerImgView sd_setImageWithURL:[NSURL URLWithString:model.company_logo] placeholderImage:[UIImage imageNamed:@"header_bg"]];
    } else {
        headerImgView.image = [UIImage imageNamed:@"header_bg"];
    }
    hrLbl.text = [NSString stringWithFormat:@"%@·%@", model.hrInfoModel.name, model.hrInfoModel.position];
    wageLbl.text = model.wage_cn;
    timeLbl.text = model.update_timeMMDD;
    
    CGFloat width = [UIToolsControl textWidth:companyName size:CGSizeMake(MAXFLOAT, 20*Scale) font:Font_15]+1;
    companyNameLbl.frame = CGRectMake(EndX(headerImgView)+10*Scale, StartY(headerImgView), MIN(width, WIDTH-100*Scale), 20*Scale);
    integrityTagImgView.frame = CGRectMake(EndX(companyNameLbl)+2, StartY(companyNameLbl)+3*Scale, 14*Scale, 14*Scale);
    if (model.company_auth_medal && model.company_auth_medal.length && [model.company_auth_medal isEqualToString:@"1"]) {
        integrityTagImgView.hidden = NO;
    } else {
        integrityTagImgView.hidden = YES;
    }
//    companyInfoLbl.frame = CGRectMake(EndX(integrityTagImgView)+3, EndY(baseInfoLbl)+8*Scale, 200, 15*Scale);
}
- (void)reloadDataModelForCollect:(CompanyJobModel *)model {
    titleLbl.text = model.job_title;
    baseInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.district_cn, model.experience_cn, model.education_cn];
    
    NSString *companyName = model.companyInfoModel.name;
    companyNameLbl.text = companyName;
    companyInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.companyInfoModel.finance_cn, model.companyInfoModel.scale_cn, model.companyInfoModel.trade_cn];
    if (model.hrInfoModel.avatar && model.hrInfoModel.avatar.length) {
        [headerImgView sd_setImageWithURL:[NSURL URLWithString:model.hrInfoModel.avatar] placeholderImage:[UIImage imageNamed:@"header_bg"]];
    } else {
        headerImgView.image = [UIImage imageNamed:@"header_bg"];
    }
    hrLbl.text = [NSString stringWithFormat:@"%@·%@", model.hrInfoModel.name, model.hrInfoModel.position];
    wageLbl.text = model.wage_cn;
    timeLbl.text = model.job_update_timeMMdd;
    
    CGFloat width = [UIToolsControl textWidth:companyName size:CGSizeMake(MAXFLOAT, 20*Scale) font:Font_15]+1;
    companyNameLbl.frame = CGRectMake(EndX(headerImgView)+10*Scale, StartY(headerImgView), MIN(width, WIDTH-100*Scale), 20*Scale);
    integrityTagImgView.frame = CGRectMake(EndX(companyNameLbl)+2, StartY(companyNameLbl)+3*Scale, 14*Scale, 14*Scale);
//    companyInfoLbl.frame = CGRectMake(EndX(integrityTagImgView)+3, EndY(baseInfoLbl)+8*Scale, 200*Scale, 15*Scale);
}

- (void)awakeFromNib {
    [super awakeFromNib];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end



/*
#import "JobCell.h"

@interface JobCell ()
{
    UILabel *titleLbl;
    UILabel *baseInfoLbl;
    UILabel *companyNameLbl;
    UIImageView *integrityTagImgView;
    UILabel *companyInfoLbl;
    UIImageView *headerImgView;
    UILabel *hrLbl;
    UILabel *wageLbl;
    UILabel *timeLbl;
}
@end

@implementation JobCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}
- (void)initUI {
    titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(LeftSpace, 15*Scale, WIDTH-100*Scale, 30*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    titleLbl.font = FontBold(Font_18);
    [self.contentView addSubview:titleLbl];
    
    baseInfoLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(titleLbl), EndY(titleLbl), ViewWidth(titleLbl), 25*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
    [self.contentView addSubview:baseInfoLbl];
    
    companyNameLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(titleLbl), EndY(baseInfoLbl)+5*Scale, 100, 20*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    [self.contentView addSubview:companyNameLbl];
    
    integrityTagImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(EndX(companyNameLbl)+2, StartY(companyNameLbl)+3*Scale, 14*Scale, 14*Scale) imageName:@"integrity_tag"];
    [self.contentView addSubview:integrityTagImgView];
    
    companyInfoLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(integrityTagImgView)+3, EndY(baseInfoLbl)+8*Scale, 200, 15*Scale) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_13];
    [self.contentView addSubview:companyInfoLbl];
    
    headerImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(StartX(titleLbl), EndY(companyNameLbl)+10*Scale, 40*Scale, 40*Scale) imageName:@"header_bg"];
    headerImgView.layer.cornerRadius = 20*Scale;
    headerImgView.layer.masksToBounds = YES;
    [self.contentView addSubview:headerImgView];
    
    hrLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(headerImgView)+10*Scale, StartY(headerImgView), 200, ViewHeight(headerImgView)) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_12];
    [self.contentView addSubview:hrLbl];
    
    wageLbl = [UIToolsControl initLabelWithFrame:CGRectMake(WIDTH-200*Scale, 20*Scale, 185*Scale, 17*Scale) text:nil textColor:THEMECOLOR_OF_RED font:Font_15];
    wageLbl.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:wageLbl];
    
    timeLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(wageLbl), EndY(wageLbl)+5*Scale, ViewWidth(wageLbl), ViewHeight(wageLbl)) text:nil textColor:THEMECOLOR_OF_TEXT_cccccc font:Font_12];
    timeLbl.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:timeLbl];
    
    UIView *lineView = [UIToolsControl initViewWithFrame:CGRectMake(0, EndY(headerImgView)+8*Scale, WIDTH, 8*Scale) backgroundColor:THEMECOLOR_OF_GRAY];
    [self.contentView addSubview:lineView];
}
- (void)reloadData {
    titleLbl.text = @"资深程序架构师—App";
    baseInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@ | %@", @"北京", @"通州", @"3-5年", @"本科"];
    
    NSString *companyName = @"同心互联";
    companyNameLbl.text = companyName;
    companyInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", @"天使轮", @"50-100人", @"移动互联网"];
//    [headerImgView sd_setImageWithURL:[NSURL URLWithString:@""]];
    hrLbl.text = @"罗宏伟.CEO";
    wageLbl.text = @"25K-35K";
    timeLbl.text = @"02月11日";
    
    CGFloat width = [UIToolsControl textWidth:companyName size:CGSizeMake(MAXFLOAT, 25*Scale) font:Font_18]+1;
    companyNameLbl.frame = CGRectMake(StartX(titleLbl), EndY(baseInfoLbl)+5*Scale, width, 20*Scale);
    integrityTagImgView.frame = CGRectMake(EndX(companyNameLbl)+2, StartY(companyNameLbl)+3*Scale, 14*Scale, 14*Scale);
    companyInfoLbl.frame = CGRectMake(EndX(integrityTagImgView)+3, EndY(baseInfoLbl)+8*Scale, 200, 15*Scale);
}
- (void)reloadDataModel:(CompanyJobModel *)model {
    titleLbl.text = model.title;
    baseInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.district_cn, model.experience_cn, model.education_cn];
    
    NSString *companyName = model.company_name;
    companyNameLbl.text = companyName;
    companyInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.finance_cn, model.scale_cn, model.trade_cn];
    if (model.hrInfoModel.avatar && model.hrInfoModel.avatar.length) {
        [headerImgView sd_setImageWithURL:[NSURL URLWithString:model.hrInfoModel.avatar] placeholderImage:[UIImage imageNamed:@"header_bg"]];
    } else {
        headerImgView.image = [UIImage imageNamed:@"header_bg"];
    }
    hrLbl.text = [NSString stringWithFormat:@"%@·%@", model.hrInfoModel.name, model.hrInfoModel.position];
    wageLbl.text = model.wage_cn;
    timeLbl.text = model.update_timeMMDD;
    
    CGFloat width = [UIToolsControl textWidth:companyName size:CGSizeMake(MAXFLOAT, 25*Scale) font:Font_18]+1;
    companyNameLbl.frame = CGRectMake(StartX(titleLbl), EndY(baseInfoLbl)+5*Scale, MIN(width, 150*Scale), 20*Scale);
    integrityTagImgView.frame = CGRectMake(EndX(companyNameLbl)+2, StartY(companyNameLbl)+3*Scale, 14*Scale, 14*Scale);
    companyInfoLbl.frame = CGRectMake(EndX(integrityTagImgView)+3, EndY(baseInfoLbl)+8*Scale, 200, 15*Scale);
}
- (void)reloadDataModelForCollect:(CompanyJobModel *)model {
    titleLbl.text = model.job_title;
    baseInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.district_cn, model.experience_cn, model.education_cn];
    
    NSString *companyName = model.companyInfoModel.name;
    companyNameLbl.text = companyName;
    companyInfoLbl.text = [NSString stringWithFormat:@"%@ | %@ | %@", model.companyInfoModel.finance_cn, model.companyInfoModel.scale_cn, model.companyInfoModel.trade_cn];
    if (model.hrInfoModel.avatar && model.hrInfoModel.avatar.length) {
        [headerImgView sd_setImageWithURL:[NSURL URLWithString:model.hrInfoModel.avatar] placeholderImage:[UIImage imageNamed:@"header_bg"]];
    } else {
        headerImgView.image = [UIImage imageNamed:@"header_bg"];
    }
    hrLbl.text = [NSString stringWithFormat:@"%@·%@", model.hrInfoModel.name, model.hrInfoModel.position];
    wageLbl.text = model.wage_cn;
    timeLbl.text = model.job_update_timeMMdd;
    
    CGFloat width = [UIToolsControl textWidth:companyName size:CGSizeMake(MAXFLOAT, 25*Scale) font:Font_18]+1;
    companyNameLbl.frame = CGRectMake(StartX(titleLbl), EndY(baseInfoLbl)+5*Scale, MIN(width, 150*Scale), 20*Scale);
    integrityTagImgView.frame = CGRectMake(EndX(companyNameLbl)+2, StartY(companyNameLbl)+3*Scale, 14*Scale, 14*Scale);
    companyInfoLbl.frame = CGRectMake(EndX(integrityTagImgView)+3, EndY(baseInfoLbl)+8*Scale, 200*Scale, 15*Scale);
}

- (void)awakeFromNib {
    [super awakeFromNib];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
*/
